package com.feditory.shop.domain;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.feditory.common.domain.DataHandleStatus;
import com.feditory.common.domain.ShopType;
import com.feditory.util.DateUtils;

@Entity
@Table(name = "SH_SHOP")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "SHOP_TYPE", length = 20, discriminatorType = DiscriminatorType.STRING)
public abstract class AbstractShop {

    /** 샵 seq */
    @Id
    @GeneratedValue(generator = "SQ_WHOLESALE_SHOP")
    @SequenceGenerator(name = "SQ_WHOLESALE_SHOP", initialValue = 1, allocationSize = 1, sequenceName = "SQ_WHOLESALE_SHOP")
    @Column(name = "ID")
    private long id;

    /** 샵아이디 */
    @Column(name = "SHOP_ID", length = 10, nullable = false)
    private String shopId;

    /** 샵명 */
    @Column(name = "SHOP_NAME", length = 255, nullable = false)
    private String shopName;

    //    /** 샵타입 */
    //    @Enumerated(EnumType.STRING)
    //    @Column(name = "SHOP_TYPE", length = 15, nullable = false)
    //    private ShopType shopType;

    /** 로그인아이디 */
    @Column(name = "LOGIN_ID", length = 255, nullable = false)
    private String loginId;

    /** 패스워드 */
    @Column(name = "PASSWORD", length = 255, nullable = false)
    private String password;

    abstract ShopType getShopType();

    @Embedded
    private DataHandleStatus handleStatus;

    public void disable() {
        if (this.handleStatus == null) return;
        this.handleStatus.setUseYn(false);
        this.handleStatus.setUpdateDateTime(DateUtils.getCurrentBaseDateString());
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getShopName() {
        return shopName;
    }

    public void setShopName(String shopName) {
        this.shopName = shopName;
    }

    public String getLoginId() {
        return loginId;
    }

    public void setLoginId(String loginId) {
        this.loginId = loginId;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public DataHandleStatus getHandleStatus() {
        return handleStatus;
    }

    public void setHandleStatus(DataHandleStatus handleStatus) {
        this.handleStatus = handleStatus;
    }

    public String getShopId() {
        return shopId;
    }

    public void setShopId(String shopId) {
        this.shopId = shopId;
    }

    //    public ShopType getShopType() {
    //        return shopType;
    //    }
    //
    //    public void setShopType(ShopType shopType) {
    //        this.shopType = shopType;
    //    }

}
